package com.one.blocks.rbac.controller.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.one.blocks.mvc.controller.valid.Custom;
import com.one.blocks.mvc.controller.valid.Update;
import com.one.blocks.mvc.controller.valid.UpdateSelective;
import com.one.blocks.mvc.domain.Id;
import com.one.blocks.rbac.controller.valid.ValidTree;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.groups.Default;
import java.io.Serializable;

/**
 * @author <a href="mailto:idler41@163.con">idler41</a> created on 2022-05-02 19:34:53
 */
@ApiModel(value = "系统组织")
@Data
@ValidTree(groups = {Custom.class})
public class SysOrgVo implements Id<Integer>, Serializable {

    /**
     * 主键ID
     */
    @ApiModelProperty(value = "主键ID")
    @NotNull(groups = {UpdateSelective.class, Update.class})
    private Integer id;

    /**
     * 上级组织id
     */
    @ApiModelProperty(value = "上级组织id")
    @Null(groups = {UpdateSelective.class})
    private Integer parentId;

    /**
     * 组织编码
     */
    @ApiModelProperty(value = "组织编码")
    @NotNull(groups = {Update.class})
    private String code;

    /**
     * 组织及以下所有编码
     */
    @ApiModelProperty(value = "组织及以下所有编码")
    private String fullCode;

    /**
     * 组织名称
     */
    @ApiModelProperty(value = "组织名称")
    @NotNull(groups = {Update.class})
    private String name;

    /**
     * 组织状态: 0-停用 1-启用
     */
    @ApiModelProperty(value = "组织状态: 0-停用 1-启用")
    @NotNull(groups = {Default.class, Update.class})
    @Range(min = 0, max = 1, groups = {Default.class, Update.class, UpdateSelective.class})
    private Integer state;

    /**
     * 显示层级
     */
    @ApiModelProperty(value = "显示层级")
    @NotNull(groups = {Update.class})
    private Integer levelNum;

    /**
     * 显示顺序
     */
    @ApiModelProperty(value = "显示顺序")
    @NotNull(groups = {Update.class})
    private Integer orderNum;

    /**
     * 创建者
     */
    @ApiModelProperty(value = "创建者", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private Integer createBy;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private Long createTime;

    /**
     * 更新者
     */
    @ApiModelProperty(value = "更新者", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private Integer updateBy;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private Long updateTime;
}